home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 242 / Issue 242 - April 2008 - DPCS0408DVD.ISO / Software Money Savers / VirtualDub / Source / VirtualDub-1.7.7-src.7z / src / Asuka / source / verinc.cpp < prev   
Encoding:
C/C++ Source or Header  |  2006-10-16  |  2.6 KB  |  105 lines

  1. //    Asuka - VirtualDub Build/Post-Mortem Utility
  2. //    Copyright (C) 2005 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "stdafx.h"
  19. #include <vd2/system/vdtypes.h>
  20. #include <string>
  21. #include <time.h>
  22.  
  23. #include "utils.h"
  24.  
  25. using namespace std;
  26.  
  27. void tool_verinc(bool amd64) {
  28.     string machine_name(get_name());
  29.  
  30.     time_t systime;
  31.     time(&systime);
  32.     tm *ts = localtime(&systime);
  33.  
  34.     const int build = get_version();
  35.  
  36.     string build_time(asctime(ts));
  37.  
  38.     build_time.erase(build_time.size()-1);        // kill terminating newline
  39.  
  40.     static const char *const sMonths[12]={
  41.         "January",
  42.         "February",
  43.         "March",
  44.         "April",
  45.         "May",
  46.         "June",
  47.         "July",
  48.         "August",
  49.         "September",
  50.         "October",
  51.         "November",
  52.         "December"
  53.     };
  54.  
  55.     char datestr[128];
  56.     sprintf(datestr, "%s %d, %d", sMonths[ts->tm_mon], ts->tm_mday, 1900 + ts->tm_year);
  57.  
  58.     FILE *f = fopen("verstub.asm", "w");
  59.     if (!f)
  60.         fail("Unable to open verstub.asm for write.");
  61.  
  62.     if (amd64)
  63.         fprintf(f,
  64.             "\t"    ".const\n"
  65.             "\n"
  66.             "\t"    "public\t"    "version_num\n"
  67.             "\t"    "public\t"    "version_time\n"
  68.             "\t"    "public\t"    "version_date\n"
  69.             "\t"    "public\t"    "version_buildmachine\n"
  70.             "\n"
  71.             "version_num\t"    "dd\t"    "%ld\n"
  72.             "version_time\t"    "db\t"    "\"%s\",0\n"
  73.             "version_date\t"    "db\t"    "\"%s\",0\n"
  74.             "version_buildmachine\t" "db\t" "\"%s\",0\n"
  75.             "\n"
  76.             "\t"    "end\n"
  77.             ,build
  78.             ,build_time.c_str()
  79.             ,datestr
  80.             ,machine_name.c_str());
  81.     else
  82.         fprintf(f,
  83.             "\t"    ".386\n"
  84.             "\t"    ".model\t"    "flat\n"
  85.             "\t"    ".const\n"
  86.             "\n"
  87.             "\t"    "public\t"    "_version_num\n"
  88.             "\t"    "public\t"    "_version_time\n"
  89.             "\t"    "public\t"    "_version_date\n"
  90.             "\t"    "public\t"    "_version_buildmachine\n"
  91.             "\n"
  92.             "_version_num\t"    "dd\t"    "%ld\n"
  93.             "_version_time\t"    "db\t"    "\"%s\",0\n"
  94.             "_version_date\t"    "db\t"    "\"%s\",0\n"
  95.             "_version_buildmachine\t" "db\t" "\"%s\",0\n"
  96.             "\n"
  97.             "\t"    "end\n"
  98.             ,build
  99.             ,build_time.c_str()
  100.             ,datestr
  101.             ,machine_name.c_str());
  102.  
  103.     fclose(f);
  104. }
  105.